<template>
    <view @tap="__e" :class="['coupon-item', active ? 'active' : 'unactive']" :data-event-opts="[['tap', [['click', ['$event']]]]]">
        <view class="detail">
            <view class="title">
                <text>{{ coupon.title }}</text>
            </view>
            <view class="label">
                <text>{{ coupon.usable_range_text }}</text>
            </view>
            <view class="label" v-if="coupon.score_price">
                <text v-if="coupon.score_price">{{ coupon.score_price + scoreAlias + '兑换' }}</text>
            </view>
            <view class="valid-date">
                <text v-if="coupon.time_limit_type == 0">{{ validDateStr }}</text>
                <block v-else>
                    <text v-if="coupon.time_limit_type == 1">{{ '领取后' + coupon.valid_time + '小时内有效' }}</text>
                </block>
            </view>
            <view class="limit-type gray">
                <view style="margin-bottom: 10rpx" v-if="coupon.max_money">{{ '最大' + coupon.max_money / 100 + '元可用' }}</view>
                <view v-if="coupon.draw_limit">{{ '抽数限制' + coupon.draw_limit }}</view>
            </view>
        </view>
        <view class="popup-num">
            <text>{{ 'X ' + coupon.usable_per_user }}</text>
        </view>
        <view class="discount-money">
            <view class="price" v-if="coupon.discount_type === 0">
                <text class="unit">¥</text>
                <text class="money">{{ coupon.discount_money / 100 }}</text>
            </view>
            <block v-else>
                <view class="price" v-if="coupon.discount_type === 1">
                    <text>{{ coupon.discount_rate / 10 }}</text>
                    <text class="unit">折</text>
                </view>
                <block v-else>
                    <view class="price" v-if="coupon.discount_type === 2">
                        <text>包邮</text>
                    </view>
                    <block v-else>
                        <view class="price small" v-if="coupon.discount_type === 3">
                            <text>兑换券</text>
                        </view>
                    </block>
                </block>
            </block>
            <view class="type">
                <text v-if="coupon.discount_type === 0">优惠券</text>
                <block v-else>
                    <text v-if="coupon.discount_type === 1">折扣券</text>
                    <block v-else>
                        <text v-if="coupon.discount_type === 2">运费券</text>
                        <block v-else>
                            <text v-if="coupon.discount_type === 3">兑换券</text>
                        </block>
                    </block>
                </block>
            </view>
            <view class="lijishiyong">立即使用</view>
        </view>
    </view>
</template>

<script>
import tabBar from '@/components/TabBar/tabBar';
(global.webpackJsonp = global.webpackJsonp || []).push([
    ['components/CouponList/components/CouponItem'],
    {
        '0863f': function (t, n, o) {
            'use strict';

            o.r(n);
            var e = o('5632');
            var u = o.n(e);
            for (var c in e) {
                if (['default'].indexOf(c) < 0) {
                    (function (t) {
                        o.d(n, t, function () {
                            return e[t];
                        });
                    })(c);
                }
            }
            n.default = u.a;
        },
        '377c': function (t, n, o) {
            'use strict';

            o.d(n, 'b', function () {
                return e;
            });
            o.d(n, 'c', function () {
                return u;
            });
            o.d(n, 'a', function () {});
            var e = function () {
                this.$createElement;
                this._self._c;
            };
            var u = [];
        },
        5632: function (t, n, o) {
            'use strict';

            (function (t) {
                Object.defineProperty(n, '__esModule', {
                    value: true
                });
                n.default = void 0;
                var o = {
                    name: 'CouponItem',
                    created: function () {
                        console.log(this.coupon);
                    },
                    props: {
                        coupon: {
                            type: Object,
                            default: function () {
                                return {};
                            }
                        },
                        active: {
                            type: Number,
                            default: 1
                        },
                        activeText: {
                            type: String,
                            default: '立即使用'
                        },
                        unActiveText: {
                            type: String,
                            default: '已使用'
                        }
                    },
                    computed: {
                        validDateStr: function () {
                            return this.coupon
                                ? 0 != this.coupon.time_limit_type
                                    ? ''
                                    : this.coupon.usable_start_at.substr(0, 10) + ' 至 ' + this.coupon.usable_end_at.substr(0, 10)
                                : '';
                        }
                    },
                    methods: {
                        click: function () {
                            t.navigateTo({
                                url: '/pages/couponDetail/index?uuid=' + this.coupon.uuid
                            });
                            this.$emit('click', this.coupon);
                        }
                    }
                };
                n.default = o;
            }.call(this, o('543d').default));
        },
        '60a7': function (t, n, o) {
            'use strict';

            o.r(n);
            var e = o('377c');
            var u = o('0863f');
            for (var c in u) {
                if (['default'].indexOf(c) < 0) {
                    (function (t) {
                        o.d(n, t, function () {
                            return u[t];
                        });
                    })(c);
                }
            }
            o('dc7e');
            var i = o('f0c5');
            var a = Object(i.a)(u.default, e.b, e.c, false, null, null, null, false, e.a, void 0);
            n.default = a.exports;
        },
        '81b9': function (t, n, o) {},
        dc7e: function (t, n, o) {
            'use strict';

            var e = o('81b9');
            o.n(e).a;
        }
    }
]);
(global.webpackJsonp = global.webpackJsonp || []).push([
    'components/CouponList/components/CouponItem-create-component',
    {
        'components/CouponList/components/CouponItem-create-component': function (t, n, o) {
            o('543d').createComponent(o('60a7'));
        }
    },
    [['components/CouponList/components/CouponItem-create-component']]
]);
</script>
<style>
@import './CouponItem.css';
</style>
